<?php
/**
 * Created by PhpStorm.
 * User: 123
 * Date: 2020/8/3
 * Time: 16:26
 */

namespace app\api\controller;

use app\service\AdverService;

/**
 * 广告
 * @author   juzi
 * @blog    https://blog.csdn.net/juziaixiao
 * @version  0.0.1
 * @datetime 2020年7月22日10:57:35
 */
class Advert extends Common
{

    /**
     * [__construct 构造方法]
     * @author   juzi
     * @blog    https://blog.csdn.net/juziaixiao
     * @version  0.0.1
     * @datetime 2020年7月22日10:57:35
     */
    public function __construct()
    {
        // 调用父类前置方法
        parent::__construct();
    }

    /**
     * [GetAdvert 构造方法]
     * @author   juzi
     * @blog    https://blog.csdn.net/juziaixiao
     * @version  0.0.1
     * @datetime 2020年7月22日10:57:35
     */
    public function GetAdvert()
    {
        $params = $this->data_get;
        $data_params = [
            'where' => ['advert_type' => $params['advert_type']],
            'page' => false,
            'field' => 'title,imgurl,bizpro_id,bizpro_type,advert_type,pop_imgurl,content,start_time,end_time,show_type',
            'm' => 0,
            'n' => 1,
            'table'=>'advert'
        ];
      $re = AdverService::DataList($data_params);
      $re = AdverService::DataDealWith($re,['from'=>'client']);
      $re['data'][0]['imgurl']=$re['data'][0]['src'];
      $re['data'][0]['imgurl']=$re['data'][0]['imgsrc'];
      $re['data'][0]['pop_imgurl']=$re['data'][0]['pop_imgsrc'];

        return json(DataReturn('获取成功', 0, $re['data'][0]));
    }
}